import ajax from './ajax'
import '../css/login.css'

let form = document.forms[0]

let q = document.getElementById('q')
q.onclick = function () {
    ajax('post', '/api/login', { username: form.username.value, password: form.password.value }).then(function (result) {
        if (result.flag) {
            alert('登陆成功')
            localStorage.setItem('token', result.token)
            location.href = 'index.html'
        } else {
            alert('用户名或密码错误');
        }
    })

}
